package com.ruoyi.business.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.BusHardwareStatusUpdate;
import com.ruoyi.business.service.IBusHardwareStatusUpdateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 硬件设备状态更新记录Controller
 * 
 * @author asher
 * @date 2021-10-24
 */
@RestController
@RequestMapping("/business/hardwareStatusUpdate")
public class BusHardwareStatusUpdateController extends BaseController
{
    @Autowired
    private IBusHardwareStatusUpdateService busHardwareStatusUpdateService;

    /**
     * 查询硬件设备状态更新记录列表
     */
    @PreAuthorize("@ss.hasPermi('business:hardwareStatusUpdate:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusHardwareStatusUpdate busHardwareStatusUpdate)
    {
        startPage();
        List<BusHardwareStatusUpdate> list = busHardwareStatusUpdateService.selectBusHardwareStatusUpdateList(busHardwareStatusUpdate);
        return getDataTable(list);
    }

    /**
     * 导出硬件设备状态更新记录列表
     */
    @PreAuthorize("@ss.hasPermi('business:hardwareStatusUpdate:export')")
    @Log(title = "硬件设备状态更新记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BusHardwareStatusUpdate busHardwareStatusUpdate)
    {
        List<BusHardwareStatusUpdate> list = busHardwareStatusUpdateService.selectBusHardwareStatusUpdateList(busHardwareStatusUpdate);
        ExcelUtil<BusHardwareStatusUpdate> util = new ExcelUtil<BusHardwareStatusUpdate>(BusHardwareStatusUpdate.class);
        return util.exportExcel(list, "硬件设备状态更新记录数据");
    }

    /**
     * 获取硬件设备状态更新记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:hardwareStatusUpdate:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return AjaxResult.success(busHardwareStatusUpdateService.selectBusHardwareStatusUpdateByRecordId(recordId));
    }

    /**
     * 新增硬件设备状态更新记录
     */
    @PreAuthorize("@ss.hasPermi('business:hardwareStatusUpdate:add')")
    @Log(title = "硬件设备状态更新记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusHardwareStatusUpdate busHardwareStatusUpdate)
    {
        return toAjax(busHardwareStatusUpdateService.insertBusHardwareStatusUpdate(busHardwareStatusUpdate));
    }

    /**
     * 修改硬件设备状态更新记录
     */
    @PreAuthorize("@ss.hasPermi('business:hardwareStatusUpdate:edit')")
    @Log(title = "硬件设备状态更新记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusHardwareStatusUpdate busHardwareStatusUpdate)
    {
        return toAjax(busHardwareStatusUpdateService.updateBusHardwareStatusUpdate(busHardwareStatusUpdate));
    }

    /**
     * 删除硬件设备状态更新记录
     */
    @PreAuthorize("@ss.hasPermi('business:hardwareStatusUpdate:remove')")
    @Log(title = "硬件设备状态更新记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(busHardwareStatusUpdateService.deleteBusHardwareStatusUpdateByRecordIds(recordIds));
    }

    /**
     * 更新硬件设备状态并且新增更新记录
     */
//    @PreAuthorize("@ss.hasPermi('business:hardwareStatusUpdate:updateStatus')")
    @Log(title = "更新硬件设备状态并且新增更新记录", businessType = BusinessType.UPDATE)
    @PostMapping("/updateStatus")
    public AjaxResult updateStatus(@RequestBody BusHardwareStatusUpdate busHardwareStatusUpdate)
    {
        return toAjax(busHardwareStatusUpdateService.updateStatusByDestRecordId(busHardwareStatusUpdate));
    }
}
